﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NativeDataOperation.Interfaces;
using DDHDeepTunnel.Data;
using DDHDeepTunnel.Interfaces;
using WebFoundation;
using WebFoundation.Data;
using log4net.Core;

namespace DDHDeepTunnel.Business
{
    internal class DDHDeepTunnelModule : WFModule, IDDHDeepTunnelModule
    {
        private readonly DbManager _dbQueryManager;
        private readonly DbManager _dbWriteManager;
        public DDHDeepTunnelModule(string queryConnectionString, string writableConnectionString)
        {
            _dbQueryManager = DbManager.FromConfig(queryConnectionString);
            _dbWriteManager = DbManager.FromConfig(writableConnectionString);
        }

        public string GetOnlineStationTypeByFactorType(string factorType)
        {
            string stationType = "";
            switch(factorType.ToLower().Trim())
            {
                case "flow":
                    stationType = "LLZ";
                    break;
                case "liquid":
                    stationType = "YWZ";
                    break;
                case "rain":
                    stationType = "YLZ";
                    break;
                case "waterquality":
                    stationType = "SZZ";
                    break;
                default:
                    stationType = "";
                    break;
            }
            return stationType;
        }

        protected override void Dispose(bool disposing)
        {
            if (!this.disposed && disposing)
            {
                _dbQueryManager.Dispose();
                _dbWriteManager.Dispose();
            }
            base.Dispose(disposing);
        }
    }
}
